import { http } from "@/utils/http";

import { type userInfoType, type regionResType } from "@/api/types";

import { baseApiUrl } from "@/utils/http/reqUrl";

/** 登录 */
export const getLogin = (data?: object) => {
  // console.log("getLogin data:", data);
  return http.postForm<{ accessToken: string }>(`${baseApiUrl}/users/login`, {
    ...data
  });
};

/**
 * 获取用户详情
 */

export const getUserInfo = () => {
  return http.request<userInfoType>(
    "get",
    `${baseApiUrl}/users/currentUserInfo`
  );
};

/**
 * 获取公共的省市区列表
 * @returns
 */
export function getCommonRegions() {
  return http.request<regionResType>("get", `${baseApiUrl}/cfg/regions`);
}
